package xyz.labmem.app.util

import javafx.scene.media.Media
import javafx.scene.media.MediaPlayer
import xyz.labmem.app.config.AppConfig
import xyz.labmem.util.getResourceFile

object BackgroundMusic {

    private var player = MediaPlayer(AppConfig.musicMedia)

    private var mona1: MediaPlayer? = null

    fun played() {
        if (player.status == MediaPlayer.Status.PLAYING) {
            player.pause()
        } else if (player.status == MediaPlayer.Status.READY || player.status == MediaPlayer.Status.UNKNOWN || player.status == MediaPlayer.Status.PAUSED || player.status == MediaPlayer.Status.STOPPED) {
            player.play()
        } else {
            player.stop()
        }
    }

    fun mona1Play() {
        mona1?.stop()
        mona1?.play()
    }

    fun init() {
        mona1 = MediaPlayer(Media(getResourceFile("sound/mona1.mp3").url.toExternalForm()))
    }
}